Remarkuple examples

Import remarkuple module:


In [1]:
from remarkuple import helper as h, table, svg

Basic HTML


In [2]:
t = h.div('text ', h.a("link"), h.b(" bold"), h.i(" italic"))
print t
t


<div>text <a>link</a><b> bold</b><i> italic</i></div>
Out[2]:
text link bold italic

HTML table


In [3]:
csv = """Title,Name,Phone
Mr.,John,07868785831
Miss,Linda,0141-2244-5566
Master,Jack,0142-1212-1234
Mr.,Bush,911-911-911"""

tbl = table()
tbl.addCaption("Contacts")
for idx, row in enumerate(csv.split("\n")):
    if idx:
        tbl.addBodyRow(h.tr(*[h.td(x) for x in row.split(",")]))
    else:
        tbl.addHeadRow(h.tr(*[h.th(x) for x in row.split(",")]))

#print tbl
tbl


Out[3]:
Contacts
TitleNamePhone
Mr.John07868785831
MissLinda0141-2244-5566
MasterJack0142-1212-1234
Mr.Bush911-911-911

SVG graphics


In [4]:
s = svg().set_axes(False).set_grid(True)
s.set_circle(r=100, fill="green", style="fill-opacity: 50%")
print s
h.br
s


<svg width="400" viewbox="0 0 401 401" height="400"><defs><pattern width="12.5" patternunits="userSpaceOnUse" id="gitem4344946448" height="12.5"><path stroke="gray" stroke-width="0.5" d="M 12.5 0 L 0 0 0 12.5" fill="none"/></pattern><pattern width="100" patternunits="userSpaceOnUse" id="gid4344946448" height="100"><path stroke="gray" stroke-width="1" d="M 100 0 L 0 0 0 100" fill="none"/><rect width="100" height="100" fill="url(#gitem4344946448)"/></pattern></defs><rect width="401" fill="white" height="401"/><rect width="401" fill="url(#gid4344946448)" height="401"/><circle style="fill-opacity: 50%" cx="200" r="100" cy="200" fill="green"/></svg>
Out[4]:

In [5]:
print svg()


<svg width="400" viewbox="0 0 401 401" height="400"/>

The MIT License

Copyright (c) 2014 Marko Manninen